home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************
- * *
- * Custom Alert Box handler *
- * *
- * Copyright (c) Clever Bits and Bitgate Software 1993 - 1994 *
- * All Rights Reserved. *
- * *
- * These routines are for handling custom alert box routines in *
- * which you can move alerts, click on them, and get information *
- * from them. That's what an ALERT is for! *
- * *
- ********************************************************************
- * *
- * To add: *
- * """"""" *
- * Calling like form_alert (string method) *
- * Windowize alert box (with its own routine to handle top window) *
- * *
- ********************************************************************
- * *
- * Update log: *
- * [3.12.93 - 5.3.94] Ken Hollis *
- * WFormCustAlert - fixed some incoherence with dialog box *
- * - fixed up the resource file (redesigned) *
- * - fixed up and added fix_objects() to start *
- * - added fix_object for 3D object stuff *
- * - fixed up resource internally to look *
- * better *
- * WInitAlert - added for initialization *
- * (global) - type casted for compatibility *
- * - optimized some places where needed *
- * *
- ********************************************************************/
-
- #include <stdio.h>
- #include <string.h>
-
- #include "winlib.h" /* WinLIB header file */
- #include "nkcc.h" /* Normalized Keycodes header file */
-
- #ifdef __TURBOC__
- #pragma warn -pia
- #endif
-
- #ifndef __ALERT__
- #define __ALERT__
- #endif
-
- static char p_to_nul[1] = "";
-
- #include "ALEXCLAM.ICN" /* GEM standard exclamation point */
- #include "ALQUEST.ICN" /* GEM standard question mark */
- #include "ALSTOP.ICN" /* GEM standard stop sign */
- #include "DEXCLAM.ICN" /* rs_object Disk exclamation point */
- #include "DQUEST.ICN" /* rs_object Disk question mark */
- #include "D_X.ICN" /* rs_object Disk with an "X" */
-
- int image_data[128] = {
- 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
- 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
- 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
- 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
- 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
- 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
- 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
- 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
-
- TEDINFO rs_tedinfo[] = {
- {" Alert box header ", p_to_nul, p_to_nul,
- 3, 0, 2, 4513, 0, -1, 19, 1},
- {"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", p_to_nul, p_to_nul,
- 3, 6, 0, 4480, 0, -1, 31, 1},
- {"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", p_to_nul, p_to_nul,
- 3, 6, 0, 4480, 0, -1, 31, 1},
- {"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", p_to_nul, p_to_nul,
- 3, 6, 0, 4480, 0, -1, 31, 1},
- {"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", p_to_nul, p_to_nul,
- 3, 6, 0, 4480, 0, -1, 31, 1},
- {"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", p_to_nul, p_to_nul,
- 3, 6, 0, 4480, 0, -1, 31, 1},
- {"Button", p_to_nul, p_to_nul,
- 3, 0, 2, 4480, 0, -2, 7, 1},
- {"Button", p_to_nul, p_to_nul,
- 3, 0, 2, 4480, 0, -3, 7, 1},
- {"Button", p_to_nul, p_to_nul,
- 3, 0, 2, 4480, 0, -2, 7, 1}
- };
-
- int imask000[] = {
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
- };
-
- int idata000[] = {
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
- };
-
- ICONBLK rs_iconblk[] = {
- {imask000, idata000, " ",
- 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020,
- 0x0020, 0x000d, 0x000e, 0x0006, 0x0008}
- };
-
- BITBLK rs_bitblk[] = { 0L };
-
- OBJECT rs_object[] = {
- /* Tree #0*/
- { -1, 1, 1,G_BOX,NONE,NORMAL, (long)(0x00001173L), 0, 0, 294, 267},
- { 0, 2, 12,G_BOX,FL3DBAK,DRAW3D, (long)(0x00ff1100L), 256, 256,1829,1802},
- { 3, -1, -1,0x1116,(FL3DACT|TOUCHEXIT),DRAW3D, (long)(&rs_tedinfo[0]), 0, 0,1829, 257},
- { 9, 4, 8,0x141A,FL3DACT,(WHITEBACK|DRAW3D), (long)(p_to_nul),1797,1537, 799, 774},
- { 5, -1, -1,G_TEXT,NONE,NORMAL, (long)(&rs_tedinfo[1]),1536,1536, 31, 1},
- { 6, -1, -1,G_TEXT,NONE,NORMAL, (long)(&rs_tedinfo[2]),1536,1537, 31, 1},
- { 7, -1, -1,G_TEXT,NONE,NORMAL, (long)(&rs_tedinfo[3]),1536,1538, 31, 1},
- { 8, -1, -1,G_TEXT,NONE,NORMAL, (long)(&rs_tedinfo[4]),1536,1539, 31, 1},
- { 3, -1, -1,G_TEXT,NONE,NORMAL, (long)(&rs_tedinfo[5]),1536,1540, 31, 1},
- { 10, -1, -1,G_ICON,NONE,NORMAL, (long)(&rs_iconblk[0]), 1,1794, 4, 4},
- { 11, -1, -1,G_BOXTEXT,(SELECTABLE|EXIT|FL3DACT),DRAW3D, (long)(&rs_tedinfo[6]),1792,1800, 266, 769},
- { 12, -1, -1,G_BOXTEXT,(SELECTABLE|EXIT|DEFAULT|FL3DACT),DRAW3D, (long)(&rs_tedinfo[7]), 782,1800, 266, 769},
- { 1, -1, -1,G_BOXTEXT,(SELECTABLE|EXIT|LASTOB|FL3DACT),DRAW3D, (long)(&rs_tedinfo[8]),1818,1800, 266, 769}
- };
-
- OBJECT *MYALERT = rs_object;
-
- ICONBLK ICONZ[] =
- {
- {(int *)(alexclam), (int *)(image_data), (char *)(p_to_nul), 0x0100, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0020,
- 0x0020, 0x000C, 0x0010, 0x0000, 0x0000},
- {(int *)(alquest), (int *)(image_data), (char *)(p_to_nul), 0x0100, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0020,
- 0x0020, 0x0010, 0x0009, 0x0000, 0x0000},
- {(int *)(alstop), (int *)(image_data), (char *)(p_to_nul), 0x0100, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0020, 0x0020,
- 0x0010, 0x000B, 0x0000, 0x0000},
- {(int *)(dexclam), (int *)(image_data), (char *)(p_to_nul), 0x0100, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0020,
- 0x0020, 0x0020, 0x0020, 0x0000, 0x0000},
- {(int *)(dquest), (int *)(image_data), (char *)(p_to_nul), 0x0100, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0020,
- 0x0020, 0x0020, 0x0020, 0x0000, 0x0000},
- {(int *)(d_x), (int *)(image_data), (char *)(p_to_nul), 0x0100, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0020, 0x0020, 0x0020,
- 0x0020, 0x0000, 0x0000}
- };
-
- #define NUM_OBS 12
- #define ALHEAD 2 /* BOXTEXT in Tree MYALERT */
- #define ALTXT1 4 /* TEXT in Tree MYALERT */
- #define ALTXT2 5 /* TEXT in Tree MYALERT */
- #define ALTXT3 6 /* TEXT in Tree MYALERT */
- #define ALTXT4 7 /* TEXT in Tree MYALERT */
- #define ALTXT5 8 /* TEXT in Tree MYALERT */
- #define ALICON 9 /* ICON in Tree MYALERT */
- #define ALBTN1 10 /* BOXTEXT in Tree MYALERT */
- #define ALBTDEF 11 /* BOXTEXT in Tree MYALERT */
- #define ALBTN2 12 /* BOXTEXT in Tree MYALERT */
- ICONBLK *ALEXCLAM = { &ICONZ[0] };
- ICONBLK *ALQUEST = { &ICONZ[1] };
- ICONBLK *ALSTOP = { &ICONZ[2] };
- ICONBLK *DEXCLAM = { &ICONZ[3] };
- ICONBLK *DQUEST = { &ICONZ[4] };
- ICONBLK *D_X = { &ICONZ[5] };
-
- /*
- * Initialize MYALERT box stuff
- *
- * This routine is to be called only at WInit time. Any other time
- * after which will cause memory problems.
- */
- GLOBAL void WInitAlert()
- {
- RFix_ObjectPos(MYALERT);
- fix_object(MYALERT, TRUE);
- }
-
- GLOBAL int WFormCustAlert(int icn, char *text1, char *at1, char *at2, char *at3, char *at4, char *at5,
- char *bt1, char *bt2, char *bt3)
- {
- int ex;
- register OBJECT *al = MYALERT;
-
- if (al[ALBTN1].ob_flags & HIDETREE)
- al[ALBTN1].ob_flags &= ~HIDETREE;
-
- if (al[ALBTDEF].ob_flags & HIDETREE)
- al[ALBTDEF].ob_flags &= ~HIDETREE;
-
- if (al[ALBTN2].ob_flags & HIDETREE)
- al[ALBTN2].ob_flags &= ~HIDETREE;
-
- switch (icn) {
- case 1: al[ALICON].ob_spec.iconblk = ALEXCLAM;
- break;
-
- case 2: al[ALICON].ob_spec.iconblk = ALQUEST;
- break;
-
- case 3: al[ALICON].ob_spec.iconblk = ALSTOP;
- break;
-
- case 4: al[ALICON].ob_spec.iconblk = DEXCLAM;
- break;
-
- case 5: al[ALICON].ob_spec.iconblk = DQUEST;
- break;
-
- case 6: al[ALICON].ob_spec.iconblk = D_X;
- break;
-
- default:al[ALICON].ob_spec.iconblk = ALSTOP;
- break;
- }
-
- if (strlen(bt1) <= 1) al[ALBTN1].ob_flags |= HIDETREE;
- if (strlen(bt2) <= 1) al[ALBTDEF].ob_flags |= HIDETREE;
- if (strlen(bt3) <= 1) al[ALBTN2].ob_flags |= HIDETREE;
-
- ChangeObjectText(al, ALHEAD, text1, 0, TE_CNTR);
- ChangeObjectText(al, ALTXT1, at1, 0, TE_LEFT);
- ChangeObjectText(al, ALTXT2, at2, 0, TE_LEFT);
- ChangeObjectText(al, ALTXT3, at3, 0, TE_LEFT);
- ChangeObjectText(al, ALTXT4, at4, 0, TE_LEFT);
- ChangeObjectText(al, ALTXT5, at5, 0, TE_LEFT);
- ChangeObjectText(al, ALBTN1, bt1, 0, TE_CNTR);
- ChangeObjectText(al, ALBTDEF, bt2, 0, TE_CNTR);
- ChangeObjectText(al, ALBTN2, bt3, 0, TE_CNTR);
-
- showdialog(al);
- ex = dodialog(VDIhandle, al, FALSE, FALSE);
- enddialog(al);
-
- if (ex == ALBTN1) return(1);
- if (ex == ALBTDEF) return(2);
- if (ex == ALBTN2) return(3);
-
- return(0);
- }